package com.wobangkj.common.repository;

import com.wobangkj.common.model.crud.Deliver;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface DeliverRepository extends JpaRepository<Deliver, Long> {
    @Query(nativeQuery = true, value="select * from  deliver  where deliverer_id=:delivererId and deliver_content_id=:deliverContentId ")
    List<Deliver> findById(String delivererId, String deliverContentId );

    @Query(nativeQuery = true, value="select l.* ,u.name,u.headimg,u.is_master from" +
            "  deliver l join user u on l.deliverer_id=u.id  where l.deliver_content_publisher_id=:Id ORDER BY l.createtime DESC; ")
    List<Map> findToMe(String Id);

    @Query(nativeQuery = true, value="select l.* ,u.name,u.headimg,u.is_master from" +
            "  deliver l join user u on l.deliver_content_publisher_id=u.id  where l.deliverer_id=:Id ORDER BY l.createtime DESC; ")
    List<Map> findMy(String Id);

    @Query(nativeQuery = true, value="select job_publisher_id from  job  where id=:ContentId ")
    public String getJobId(String ContentId );
}
